home *** CD-ROM | disk | FTP | other *** search
/ Clipper Collection / Clipper Collection.iso / clipper7 / nannws23.arc / RPT_HEAD.PRG < prev   
Text File  |  1988-03-14  |  4KB  |  100 lines

  1. * REPORT FORM: Header Option
  2. *
  3. * Call RL.EXE and proceed as usual with this exception: the page
  4. * header must be defined as four lines of 60 characters each.
  5. * Any characters will do; they will be changed anyway.  Then call
  6. * the UDF before the REPORT FORM command.  Pass the four elements
  7. * of the array; each will be a line of the header.  If you pass a
  8. * null string, the result is a blank line.  If you pass an 
  9. * invalid type (only a character string is valid), the line will 
  10. * be untouched.  The UDF centers and pads the lines.
  11. *
  12. * Example main program to use the UDF()
  13. * Author: Bao Hoang
  14. *
  15. *--Notes:  When the report form file is created, all lines of
  16. *     the report form file header must be filled in with some
  17. *     space holders.  For example, enter 60 X's for all lines
  18. *     in the header of the report form.
  19. *----------------------------------------------------------------
  20. *--Sample output:
  21. *
  22. *--Before:
  23. *
  24. * Page No.     1
  25. * 02/05/88
  26. *       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  27. *       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  28. *       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  29. *       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  30. *
  31. *
  32. *--After:
  33. *
  34. * Page No.     1
  35. * 02/05/88
  36. *                              This is line 1
  37. *                                  line 2
  38. *                                 hjfhgjdf
  39. *
  40. *----------------------------------------------------------------
  41. clear
  42. use c:\source2\mems
  43. set printer to bao.txt
  44. declare arr[4]     && array of 4 elements (1 element/header line)
  45. arr[1] = "This is line 1"
  46. arr[2] = "line 2"
  47. arr[3] = "hjfhgjdf"
  48. arr[4] = " "           && blank out last line
  49.  
  50. if UDF("bao.frm",arr)
  51.    report form bao to print
  52. else
  53.    ? "report form couldn't be modified!!"
  54. endif
  55. return
  56.  
  57.  
  58. *--UDF to modify .FRM file on-the-fly
  59. function udf
  60. para fn,arr                  && fn = filename
  61.                              && arr = array of header strings
  62.  
  63. private handle,;             && file handle
  64.         offset,;             && offset of file to read
  65.         tmp,;                && temporary work variable
  66.         buffer,;             && buffer to hold offset value read
  67.         string,;             && header string
  68.         rv,;                 && return value (TRUE/FALSE)
  69.         i,;                  && loop counter
  70.         roffset              && rela offset
  71.  
  72. buffer = " "                 && init buffer
  73.  
  74. handle=FOPEN(fn,2)           && open the file
  75.  
  76. IF handle != -1
  77.    FSEEK(handle,1965,0)         && move file pointer to pointer
  78.    FREAD(handle,@buffer,1)      && read the offset pointer value
  79.    offset = VAL(buffer)         && convert from string to numeric
  80.    offset = 225 + offset - 1    && calculate real offset
  81.    rv = .t.
  82.    FOR i = 0 to 3
  83.       IF TYPE("arr[I+1]") = "C"
  84.          roffset = offset + (i * 61)
  85.          string = arr[i+1]
  86.          FSEEK(handle,roffset,0)      && move file pointer to
  87.                                       &&    real offset
  88.          tmp = (60 - LEN(string)) / 2 && center header
  89.          string = SPACE(tmp)+string   &&   "     "
  90.          tmp = 60 - LEN(string)       &&   "     "
  91.          string = string + SPACE(tmp) &&   "     "
  92.          FWRITE(handle,string,60)     && write it out
  93.       ENDIF
  94.    NEXT
  95.    FCLOSE(handle)               && close the file
  96. ELSE
  97.    rv = .f.                     && couldn't open file
  98. ENDIF
  99. return(rv)                      && let's go home charlie
  100.